3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">
\r
9 Ext.onReady(function() {
\r
11 // The only requirement for this to work is that you must have a hidden field and
\r
12 // an iframe available in the page with ids corresponding to Ext.History.fieldId
\r
13 // and Ext.History.iframeId. See history.html for an example.
\r
16 // Needed if you want to handle history for multiple components in the same page.
\r
17 // Should be something that won't be in component ids.
\r
18 var tokenDelimiter = ':';
\r
20 var tp = new Ext.TabPanel({
\r
21 renderTo: Ext.getBody(),
\r
32 tabPosition: 'bottom',
\r
46 'tabchange': function(tabPanel, tab){
\r
47 Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
\r
65 'tabchange': function(tabPanel, tab){
\r
66 // Ignore tab1 since it is a separate tab panel and we're managing history for it also.
\r
67 // We'll use its handler instead in that case so we don't get duplicate nav events for sub tabs.
\r
68 if(tab.id != 'tab1'){
\r
69 Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
\r
75 // Handle this change event in order to restore the UI to the appropriate history state
\r
76 Ext.History.on('change', function(token){
\r
78 var parts = token.split(tokenDelimiter);
\r
79 var tabPanel = Ext.getCmp(parts[0]);
\r
80 var tabId = parts[1];
\r
83 tabPanel.setActiveTab(tabId);
\r
85 // This is the initial default state. Necessary if you navigate starting from the
\r
86 // page without any existing history token params and go back to the start state.
\r
88 tp.getItem(0).setActiveTab(0);
\r